package com.deer.wms.ware.task.web;

import com.deer.wms.project.root.util.DateUtils;
import com.deer.wms.ware.task.model.WCS.WcsInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;
import com.deer.wms.project.root.core.result.Result;
import com.deer.wms.project.root.core.result.ResultGenerator;

/**
* Created by  on 2020/06/14.
*/
@RestController
@RequestMapping("/wcs/infos")
public class WcsInfoController {


    private static  WcsInfo wcsInfo ;


    @GetMapping("/getWcsInfo1")
    @ResponseBody
    public static WcsInfo getWcsInfo1(){
        if(wcsInfo==null){
            return  null;
        }else {
            /*Date now = DateUtils.getNowDate();
            long diff = now.getTime() - wcsInfo.getCreateTime().getTime();
            if(diff>5000){  //19895
                return null;
            }*/
            return  wcsInfo;
        }

    }
    @PostMapping("/add")
    @ResponseBody
    public Result add(@RequestBody WcsInfo wcsInfo1) {
        wcsInfo = wcsInfo1;
        wcsInfo.setCreateTime(DateUtils.getNowDateTimeString());
        // wcsInfoService.save(wcsInfo);
        return ResultGenerator.genSuccessResult();
    }


    @GetMapping("/getWcsInfo")
    @ResponseBody
    public Result getWcsInfo() {
        return ResultGenerator.genSuccessResult(wcsInfo);
    }


}
